package com.cooper.dao.core;

import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.ReturnGeneratedKeys;
import net.paoding.rose.jade.annotation.SQL;

import com.cooper.entity.SchedulerInfo;

@DAO
public interface SchedulerDAO {
	
	@SQL("select * from srd_scheduler where deleted='n' order by sort_no asc")
	List<SchedulerInfo> queryForList();
	
	@SQL("select * from srd_scheduler where deleted='n' and id=:1 ")
	SchedulerInfo loadById(Long id);
	
	@SQL("select * from srd_scheduler where deleted='n' and job_name=:1 ")
	SchedulerInfo getScheduler(String jobName);
	
	@ReturnGeneratedKeys
	@SQL("insert into srd_scheduler(creator,modifier,gmt_create,gmt_modified,job_name,job_class,"
			+ "cron_text,sort_no,depend_names,comments) values(:1.creator,:1.modifier,:1.gmtCreate,:1.gmtModified,"
			+ ":1.jobName,:1.jobClass,:1.cronText,:1.sortNo,:1.dependNames,:1.comments) ")
	Long addScheduler(SchedulerInfo sched);
	
	@SQL("update srd_scheduler set modifier=:1.modifier,gmt_modified=:1.gmtModified,"
			+ "job_name=:1.jobName,job_class=:1.jobClass,cron_text=:1.cronText,"
			+ "sort_no=:1.sortNo,depend_names=:1.dependNames,comments=:1.comments where deleted='n' and id=:1.id ")
	int updateScheduler(SchedulerInfo sched);
	
	@SQL("update srd_scheduler set modifier=:1.modifier,gmt_modified=:1.gmtModified,deleted='y' where id=:1.id ")
	int deleteScheduler(SchedulerInfo sched);
}
